package com.huqing.icu.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

;

/**
 * @Description 知识库接口，这个接口是参考参照尚硅谷的
 * @Author huqing
 * @Date 2025/6/7 14:11
 **/
@RequiredArgsConstructor
@RestController
@RequestMapping("/api/rag/chat")
@Tag(name = "AI对话接口")
public class RagController {

    @Autowired
    private ChatClient chatClient;

    /*@Autowired
    private VectorStore vectorStore;*/


    @GetMapping(value = "/v1", produces = "text/html;charset=utf-8")
    public Flux<String> chatV1() {
        String prompt = "打工人的理想是是什么";

        //.advisors(new QuestionAnswerAdvisor(vectorStore))，没有加这个代码，就不会去向量数据库检索，而是大模型自己回答
        return chatClient.prompt().user(prompt).stream().content();
    }

    /*@GetMapping(value = "/v2", produces = "text/html;charset=utf-8")
    public Flux<String> chatV2() {
        //String prompt = "打工人的理想是什么";
        String prompt = "对打工人来说，他最大的期望是什么";

        //.advisors(new QuestionAnswerAdvisor(vectorStore))，这个代码就是为了去向量数据库检索
        return chatClient.prompt().user(prompt).advisors(new QuestionAnswerAdvisor(vectorStore)).stream().content();
    }*/
}
